package com.etc;


import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;

import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

/**
 * @Auther: zhezhe
 * @Date: 2018/10/1914:56
 * @Description:
 */
public class JobTest {
    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
        //配置
        Configuration configuration = new Configuration();

        //获取一个工作
        Job job = Job.getInstance(configuration);
        //设置工作类是哪个
        job.setJarByClass(JobTest.class);
        //设置 Mapper类和reducer类是哪个
        job.setMapperClass(MapTest.class);
        job.setReducerClass(Reducer.class);
        //设置key 和 value
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(IntWritable.class);
        //指定输入输出的目录
        FileInputFormat.setInputPaths(job,new Path("f:\\123.txt"));
        FileOutputFormat.setOutputPath(job,new Path("f:\\output"));
        //设置reducer的输出数目
        job.setNumReduceTasks(1);

        boolean res = job.waitForCompletion(true);
        System.exit(res?0:1);
    }
}
